package com.itheima.controller;

import com.itheima.domain.Book;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/books")
public class BookController {
    @PostMapping
    public String save(@RequestBody Book book){
        System.out.println("book save"+book);
        return "{'module':'book save sucess'}";
    }
    @GetMapping
    public List<Book> getAll(){
        System.out.println("book get all");
        List<Book> list = new ArrayList<Book>();
        Book book = new Book();
        book.setType("计算机");
        book.setName("SpringMvc");
        book.setDescription("小试牛刀");
        list.add(book);
        return list;
    }
}
